﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
        /* Type Messages in Console:
        0 - Info Message
        1 - Error Message
        2 - Quest Message
        3 - Debug Message
        4 - Good Message
        */ 
namespace Room
{
    class ConsoleHandle:Config
    {
        /*  Colors  */
        static public string cRead = GetConfig("Colors", "read");
        static public string wI = GetConfig("Colors", "wInfo");
        static public string wE = GetConfig("Colors", "wError");
        static public string wQ = GetConfig("Colors", "wQuest");
        static public string wD = GetConfig("Colors", "wDebug");
        static public string wG = GetConfig("Colors", "wGood");

        static public ConsoleColor getColor(string col)
        {
            switch (col)
            {
                case "Black": return ConsoleColor.Black;
                case "Blue": return ConsoleColor.Blue;
                case "Cyan": return ConsoleColor.Cyan;
                case "DarkBlue": return ConsoleColor.DarkBlue;
                case "DarkCyan": return ConsoleColor.DarkCyan;
                case "DarkGray": return ConsoleColor.DarkGray;
                case "DarkGreen": return ConsoleColor.DarkGreen;
                case "DarkMagenta": return ConsoleColor.DarkMagenta;
                case "DarkRed": return ConsoleColor.DarkRed;
                case "DarkYellow": return ConsoleColor.DarkYellow;
                case "Gray": return ConsoleColor.Gray;
                case "Green": return ConsoleColor.Green;
                case "Magenta": return ConsoleColor.Magenta;
                case "Red": return ConsoleColor.Red;
                case "White": return ConsoleColor.White;
                case "Yellow": return ConsoleColor.Yellow;
                default: return ConsoleColor.Gray;
            };
        }

        /*  ******  */
        static private string getDateAndTime(int level)
        {
            string d = DateTime.Now.Day.ToString();
            string m = DateTime.Now.Month.ToString();
            string y = DateTime.Now.Year.ToString();

            string c = DateTime.Now.Hour.ToString();
            string M = DateTime.Now.Minute.ToString();
            string s = DateTime.Now.Second.ToString();

            switch (level)
            {
                case 0: return "[" + c + ":" + M + ":" + s + "]";
                case 1: return "[" + d + "." + m + "." + y + " - " + c + ":" + M + ":" + s + "]";
                default: return "none";
            }
        }
        public static string read()
        {
            Console.ForegroundColor = getColor(cRead);
            Console.Write("[server]<<");
            return Console.ReadLine();
        }

        public static void write(int type, string shto)
        {
         /*
         0 - Info Message
         1 - Error Message
         2 - Quest Message
         3 - Debug Message
         4 - Good Message */
            switch (type)
            {
                case 0: Console.ForegroundColor = getColor(wI); break;
                case 1: Console.ForegroundColor = getColor(wE); break;
                case 2: Console.ForegroundColor = getColor(wQ); break;
                case 3: Console.ForegroundColor = getColor(wD); break;
                case 4: Console.ForegroundColor = getColor(wG); break;
            }

            if (type == 3) Console.WriteLine(shto);else
            if (type == 2) Console.Write("        [" + shto + "]<<");
            else
            {
                if (Config.GetConfig("Params", "showTime") == "1") Console.Write(getDateAndTime(0) + "[server]>>" + shto + "\n");
                else Console.Write("[server]>>" + shto + "\n");
            }
        }
    }
}
